package com.lamber.framework.exception;


import com.lamber.framework.util.UtilException;

/**
 * 业务异常
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = -695542791928644578L;
    protected int status = 400;

    public BusinessException(String message) {
        super(message);
        this.status = 400;
    }

    public BusinessException(Throwable cause) {
        super(UtilException.getBootMessage(cause));
        this.status = 400;
    }

    public BusinessException(String message, int status) {
        super(message);
        if (status < 1000) {
            throw new RuntimeException("status value must greater than 1000");
        } else {
            this.status = status;
        }
    }

    public BusinessException(String message, Throwable cause, int status) {
        super(message, cause);
        if (status < 1000) {
            throw new RuntimeException("status value must greater than 1000");
        } else {
            this.status = status;
        }
    }

    public int getStatus() {
        return this.status;
    }
}
